package com.m2bshop.shop.service.impl;

import com.m2bshop.shop.dao.JMFgoodsDao;
import com.m2bshop.shop.dao.JmfOrderDao;
import com.m2bshop.shop.pojo.Favorites;
import com.m2bshop.shop.pojo.JM;
import com.m2bshop.shop.pojo.JMFgoods;
import com.m2bshop.shop.service.JMFgoodsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author asus
 * @create 2022/6/12 15:43
 */
@Service
public class JMFgoodsServiceImpl implements JMFgoodsService {
    @Autowired
    private JMFgoodsDao jmFgoodsDao;
    @Autowired
    private JmfOrderDao jmfOrderDao;

    public List<JMFgoods> queryAll() {
        List<JMFgoods> jmFgoods = jmFgoodsDao.GetGoodsList();
        return jmFgoods;
    }

    /*public JMFgoods queryById(int id){
        JMFgoods jmFgoods = jmFgoodsDao.GetGoodsById(id);
        return jmFgoods;
    }*/

    @Override
    public int add(int id, Integer userId) {
        JMFgoods goodsInfo = jmFgoodsDao.getGoodsInfo(id);
        Favorites favorites = new Favorites();
        BeanUtils.copyProperties(goodsInfo,favorites);
        favorites.setId(null);
        favorites.setUserid(userId);

        int i =jmFgoodsDao.AddGoods(favorites);
        return i;
    }

    @Override
    public int add1(int id, Integer userId) {
        JMFgoods goodsInfo = jmFgoodsDao.getGoodsInfo(id);
        JM jm = new JM();
        BeanUtils.copyProperties(goodsInfo,jm);
        jm.setId(null);
        jm.setUserid(userId);
        int i =jmFgoodsDao.AddGoodsa(jm);
        return i;
    }
    @Override
    public int seleo(int id){
        int i =jmFgoodsDao.selgid(id);
        return i;
    }

    /*@Override
    public int updategood(JMFgoods goods) {
        int i = jmFgoodsDao.updateGoods(goods);
        return i;
    }

    @Override
    public int deletegood(int id) {
        int i = jmFgoodsDao.deleteGoods(id);
        return i;
    }*/
}
